package com.yinzifan.manager.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import com.yinzifan.api.events.ProductStatusEvent;
import com.yinzifan.entity.enums.ProductStatus;

@Component
public class ProductStatusManager {

	private final String MQ_DESINATION= "VirtualTopic.PRODUCT_STATUS";
	
	@Autowired
	private JmsTemplate jmsTemplate;
	
	public void changeStatus(String id, ProductStatus status) {
		ProductStatusEvent event = new ProductStatusEvent(id, status);
		jmsTemplate.convertAndSend(MQ_DESINATION, event);
	}
}
